package com.fable.ntzw_ga.entity;

import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Accessors(chain = true)
@Table(appliesTo = "feast_user",comment="酒席用户表")
public class FeastUser implements Serializable, UserDetails {
    private static final long serialVersionUID = 1L;

    @Id
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "用户id")
    @Column(name = "id", columnDefinition = "bigint(0) AUTO_INCREMENT COMMENT '用户id'")
    private Long id;

    @ApiModelProperty(value = "账户")
    @Column(name = "user_name", columnDefinition = "varchar(32) COMMENT '账户'")
    @TableField(value = "user_name")
    private String username;

    @ApiModelProperty(value = "密码")
    @Column(name = "pass_word", columnDefinition = "varchar(32) COMMENT '密码'")
    @TableField(value = "pass_word")
    private String password;

    @ApiModelProperty(value = "手机号码")
    @Column(name = "phone_number", columnDefinition = "varchar(36) COMMENT '手机号码'")
    private String phoneNumber;

    @ApiModelProperty(value = "创建时间")
    @Column(name = "create_time", columnDefinition = "datetime(0) COMMENT '创建时间'")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date createTime = new Date();

    @ApiModelProperty(value = "修改时间")
    @Column(name = "update_time", columnDefinition = "datetime(0) COMMENT '修改时间'")
    private Date updateTime;

    @ApiModelProperty(value = "是否启用 1是 0否")
    @Column(name = "enabled", columnDefinition = "tinyint(0) COMMENT '是否启用 1是 0否'")
    private Boolean enabled;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.enabled;
    }
}
